#coding = utf-8
print('输入一维数组，用空格区分：')
A = [int(n) for n in input().split()]
def bk(x , li=[]):
    if not li:
        li = []
    for i in range(int(len(A))):
        a = -(x % int(len(A)))
        li.append(A[a])
        x -= 1
    return li
def f(y):
    f_y = 0
    for n in range(int(len(A))):
        f_y += n*bk(y)[n]
    return f_y
end = []
for j in range(int(len(A))):
    end.append(f(j))
print(max(end))